Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent dynamic field overwrite when building dynamic row #401

Conversation

rakuzen25
Copy link

See #399 for context

This should fix the non-deterministic behaviour of dynamic fields; however, the behaviour when the user provides a non-empty dynamic field should be discussed.

@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rakuzen25

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot
Copy link

Welcome @rakuzen25! It looks like this is your first PR to milvus-io/milvus-sdk-node 🎉

@rakuzen25 rakuzen25 force-pushed the fix/prevent-dynamic-field-overwrite branch from 6bac264 to 0d14522 Compare December 26, 2024 09:41
Comment on lines +474 to +480
// do this last to prevent any non-deterministic behavior with loop order
if (originRow[dynamicFieldName]) {
// extend the dynamic field object with the input dynamic field object
row[dynamicFieldName] = row[dynamicFieldName] || ({} as JSON);
Object.assign(row[dynamicFieldName] as JSON, originRow[dynamicFieldName]);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the intended behaviour when the input data is something like:

{
    $meta: {
        key2: "value22",
    },
    key1: "value1",
    key2: "value2",
}

where key2 is a dynamic field not specified in the schema.

@shanghaikid
Copy link
Contributor

Thank you for the contribution, I have a better solution here. can you help on review this.

#402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants